package com.ywu.dev.admin.standard.api;

import com.ywu.common.result.CommonResult;
import com.ywu.dev.admin.spi.entity.YwuDevOpsGlobalEntity;
import com.ywu.dev.admin.standard.dto.YwuDevOpsDto;
import com.ywu.dev.admin.standard.service.YwuDevOpsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName YwuDevCommonApi
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/11/24 12:02
 * @Version 1.0
 **/
@RestController
@RequestMapping("/ywu/dev")
public class YwuDevCommonApi {

    @Autowired
    private YwuDevOpsService service;

    /**
    * @Author GroundDemo
    * @Description 查询微服务信息
    * @Date 12:37 2024/11/24
    * @Param [ywuDevOpsDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.service.info")
    public CommonResult<Object> queryServiceInfo(@RequestBody YwuDevOpsDto ywuDevOpsDto) {
        return service.queryServiceInfo(ywuDevOpsDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询服务元数据
    * @Date 20:27 2024/11/24
    * @Param [ywuDevOpsDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.query.service.metadata.info")
    public CommonResult<Object> queryServiceMetaDataInfo(@RequestBody YwuDevOpsDto ywuDevOpsDto) {
        return service.queryServiceMetaDataInfo(ywuDevOpsDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询服务实例信息
    * @Date 20:22 2024/11/24
    * @Param [ywuDevOpsDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.query.service.detail.info")
    public CommonResult<Object> queryServiceDetailInfo(@RequestBody YwuDevOpsDto ywuDevOpsDto) {
        return service.queryServiceDetailInfo(ywuDevOpsDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询服务进程信息
    * @Date 12:57 2024/11/25
    * @Param [ywuDevOpsDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.query.service.process.info")
    public CommonResult<Object> queryServiceProcessInfo(@RequestBody YwuDevOpsDto ywuDevOpsDto) {
        return service.queryServiceProcessInfo(ywuDevOpsDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询CPU使用率列表
    * @Date 19:38 2024/11/25
    * @Param [ywuDevOpsDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.query.service.cpu.info")
    public CommonResult<Object> queryServiceCpuInfo(@RequestBody YwuDevOpsDto ywuDevOpsDto) {
        return service.queryServiceCpuInfo(ywuDevOpsDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询服务GC信息
    * @Date 12:17 2024/11/26
    * @Param [ywuDevOpsDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.query.service.gc.info")
    public CommonResult<Object> queryServiceGcInfo(@RequestBody YwuDevOpsDto ywuDevOpsDto) {
        return service.queryServiceGcInfo(ywuDevOpsDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询服务线程相关信息
    * @Date 12:21 2024/11/26
    * @Param [ywuDevOpsDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.query.service.thread.info")
    public CommonResult<Object> queryServiceThreadInfo(@RequestBody YwuDevOpsDto ywuDevOpsDto) {
        return service.queryServiceThreadInfo(ywuDevOpsDto);
    }

    /**
    * @Author GroundDemo
    * @Description 查询服务的内存信息
    * @Date 13:39 2024/11/26
    * @Param [ywuDevOpsDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.query.service.memory.info")
    public CommonResult<Object> queryServiceMemoryInfo(@RequestBody YwuDevOpsDto ywuDevOpsDto) {
        return service.queryServiceMemoryInfo(ywuDevOpsDto);
    }

    /**
    * @Author GroundDemo
    * @Description 服务动态上报信息
    * @Date 12:15 2025/3/25
    * @Param []
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/dev.ops.service.report.info")
    public CommonResult<Object> serviceReportInfo(@RequestBody YwuDevOpsGlobalEntity entity) {
        // 异步执行
        service.serviceReportInfo(entity);
        return CommonResult.success(null);
    }
}
